﻿<%@ WebHandler Language="C#" Class="property" %>


using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public class property : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        SqlDataReader dr = null;
        SqlConnection conn = null;
        SqlCommand cmd = null;
        SqlCommand cmd1 = null;
        SqlDataReader dr1 = null;
        SqlConnection conn1 = null;

        try
        {


            conn = new SqlConnection(System.Configuration.ConfigurationManager.
                 ConnectionStrings["ConnStr"].ConnectionString);


            string str1 = context.Request["p_id"].ToString();
            // context.Response.Write(str1+"hhhh");
            cmd = new SqlCommand("select profile_pic from properties_rent where p_id='" + str1 + "' ", conn);

            //id>((SELECT MAX(id) FROM chat)-50) ORDER BY id ASC
            //cmd.Parameters.AddWithValue("@email", context.Session["email"]);
            conn.Open();
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {

                context.Response.ContentType = "image/jpg";
                context.Response.BinaryWrite((byte[])dr["profile_pic"]);

            }
            if (dr != null)
                dr.Close();
        }

        finally
        {
            {
                conn1 = new SqlConnection(System.Configuration.ConfigurationManager.
                    ConnectionStrings["ConnStr"].ConnectionString);
                conn1.Open();
                cmd1 = new SqlCommand("select profile_pic from profile_picc ", conn1);

                dr1 = cmd1.ExecuteReader();
                while (dr1.Read())
                {

                    context.Response.ContentType = "image/jpg";
                    context.Response.BinaryWrite((byte[])dr1["profile_pic"]);

                }

                dr1.Close();
            }
        }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}